<?php

namespace App\Repository;

use App\Models\User;
use Illuminate\Support\Facades\Hash;

class UserRepo
{
    public static function create($user)
    {
        $type = $user['type'];
        $name = $user['name'] ?? RandomRepo::username();
        $data = [
            'name' => $name,
            'password' => bcrypt($name.'_dict)123'),
            'extra' => [$type => $user['extra'], $type.'_openid' => $user['openid']],
        ];

        return User::query()->create($data);
    }
}
